package org.dftproject.patml.data;

import java.util.Set;

import org.dftproject.genesis.data.IAttribute;
import org.dftproject.genesis.data.genealogy.IRole;
import org.dftproject.genesis.data.genealogy.impl.PersonImpl;

public abstract class LazyPerson extends PersonImpl {

	private boolean initialized = false;

	@Override
	public Set<IAttribute> getAttributes() {
		if (!initialized) {
			initialized = true;
			init();
		}
		return super.getAttributes();
	}

	@Override
	public Set<IAttribute> getAttributes(String name) {
		if (!initialized) {
			initialized = true;
			init();
		}
		return super.getAttributes(name);
	}

	@Override
	public Set<IRole> getRoles() {
		if (!initialized) {
			initialized = true;
			init();
		}
		return super.getRoles();
	}

	@Override
	public Set<IRole> getRoles(String type) {
		if (!initialized) {
			initialized = true;
			init();
		}
		return super.getRoles(type);
	}

	@Override
	public Set<IRole> getRoles(String[] types) {
		if (!initialized) {
			initialized = true;
			init();
		}
		return super.getRoles(types);
	}

	protected abstract void init();

}
